package com.hgx.common.exception;


import com.hgx.common.rest.response.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * CommonExceptionHandler 异常统一处理
 */
@RestControllerAdvice
@Slf4j
public class CommonExceptionHandler {
    /**
     * 自定义异常
     */
    @ExceptionHandler(CommonException.class)
    public CommonResponse handleCommonException(CommonException e) {
        log.info("CommonExceptionHandler统一异常处理,{}",e.toString());
        return CommonResponse.error(e.getCode(), e.getMsg(), e.getData());
    }

}
